﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;

namespace DAL
{
	public class LYDODENKHAMDAO:DALBase
	{
		public LYDODENKHAMDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPLYDODENKHAM"; }
			set { _SpName = value; }
		}
		public DataTable GetListLD()
		{
			dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LYDODENKHAM(), null), ConvertClassToArray.GetValues(new LYDODENKHAM(), 0));
				return dt;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LD"); }
		}
		public List<LYDODENKHAM> GetListLDs()
		{
			dt = new DataTable();
			List<LYDODENKHAM> ds = new List<LYDODENKHAM>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LYDODENKHAM(), null), ConvertClassToArray.GetValues(new LYDODENKHAM(), 0));
				ds = (List<LYDODENKHAM>)ConvertDatatableToList.ConvertTo<LYDODENKHAM>(dt);
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LD"); }
			return ds;
		}
		public String CreatenewId()
		{
			try
			{
				return "LD" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new LYDODENKHAM(), null), ConvertClassToArray.GetValues(new LYDODENKHAM(), 1));

			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't Create new LD"); }
		}
		public bool INSERT(LYDODENKHAM cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

			}
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Insert new LD"); }
		}
		public bool UPDATE(LYDODENKHAM cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

			}
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Update  LD"); }
		}
		public bool DELETE(LYDODENKHAM cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

			}
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Delete  LD"); }
		}
	}
}
